package edu.towson.cosc603.coffeemaker;

import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RecipeTest extends TestCase {


	private CoffeeMaker cm;
	private Inventory i;
	private Recipe r1;

	@Before
	public void setUp() throws Exception {
		cm = new CoffeeMaker();
		i = cm.checkInventory();

		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(1);
	}

	@After
	public void tearDown() throws Exception {
		cm = null;
		i = null;
		r1 = null;
	}

	/*
	 * Test getAmtChocoloate, should return 1
	 */
	@Test
	public void testGetAmtChocolate1() {
		assertEquals(1, r1.getAmtChocolate());
	}

	/*
	 * Test getAmtChocoloate, with negative
	 * value, should return 0
	 */
	@Test
	public void testGetAmtChocolate2() {
		r1.setAmtChocolate(-1);
		assertNotSame(-1, r1.getAmtChocolate());
	}

	
	/*
	 * Test setAmtChocolate, should be 2
	 */
	@Test
	public void testSetAmtChocolate1() {
		r1.setAmtChocolate(2);
		assertEquals(2, r1.getAmtChocolate());
	}

	/*
	 * Test setAmtChocolate, should not take 
	 * negative value, return 0
	 */
	@Test
	public void testSetAmtChocolate2() {
		r1.setAmtChocolate(2);
		assertEquals(2, r1.getAmtChocolate(), 0);
	}
	
	/*
	 * Test setAmtChocolate, should return 0
	 */
	@Test
	public void testSetAmtChocolate3() {
		r1.setAmtChocolate(0);
		assertEquals(0, r1.getAmtChocolate());
	}
	
	/* 
	 * Test getAmtCoffee, should return 6
	 */
	@Test
	public void testGetAmtCoffee() {
		assertEquals(6, r1.getAmtCoffee());
	}

	/* 
	 * Test setAmtCoffee, should return 3
	 */
	@Test
	public void testSetAmtCoffee1() {
		r1.setAmtCoffee(3);
		assertEquals(3, r1.getAmtCoffee());
	}

	/* 
	 * Test setAmtCoffee, should not take
	 * negative value, return 0
	 */
	@Test
	public void testSetAmtCoffee2() {
		r1.setAmtCoffee(-3);
		assertEquals(0, r1.getAmtCoffee());
	}

	/* 
	 * Test setAmtCoffee, should return 0
	 */
	@Test
	public void testSetAmtCoffee3() {
		r1.setAmtCoffee(0);
		assertEquals(0, r1.getAmtCoffee());
	}
	
	/* 
	 * Test getAmtMilk, should return 1
	 */
	@Test
	public void testGetAmtMilk() {
		assertEquals(1, r1.getAmtMilk());
	}

	/* 
	 * Test setAmtCoffee, should return 1
	 */
	@Test
	public void testSetAmtMilk1() {
		r1.setAmtMilk(1);
		assertEquals(1, r1.getAmtMilk());
	}

	/* 
	 * Test setAmtCoffee, should not take 
	 * negative value, return 0
	 */
	@Test
	public void testSetAmtMilk2() {
		r1.setAmtMilk(-1);
		assertEquals(0, r1.getAmtMilk());
	}

	/* 
	 * Test setAmtCoffee, should return 0
	 */
	@Test
	public void testSetAmtMilk3() {
		r1.setAmtMilk(0);
		assertEquals(0, r1.getAmtMilk());
	}

	@Test
	public void testGetAmtSugar() {
		assertEquals(1, r1.getAmtSugar());
	}

	/* 
	 * Test setAmtCoffee, should return 1
	 */
	@Test
	public void testSetAmtSugar1() {
		r1.setAmtSugar(10);
		assertEquals(10, r1.getAmtSugar());
	}

	/* 
	 * Test setAmtCoffee, should not take 
	 * negative value, return 0
	 */
	@Test
	public void testSetAmtSugar2() {
		r1.setAmtSugar(-1);
		assertEquals(0, r1.getAmtSugar());
	}

	/* 
	 * Test setAmtCoffee, should return 0
	 */
	@Test
	public void testSetAmtSugar3() {
		r1.setAmtSugar(0);
		assertEquals(0, r1.getAmtSugar());
	}

	/*
	 * Test getName, should return Coffee
	 */
	@Test
	public void testGetName() {
		assertEquals("Coffee", r1.getName());
	}

	/*
	 * Test setName, should return PurpleDrank
	 */
	@Test
	public void testSetName1() throws Exception {
		r1.setName("PurpleDrank");
		assertEquals("PurpleDrank", r1.getName());
	}

	/*
	 * Test getPrice, should return 50
	 */
	@Test
	public void testGetPrice() {
		assertEquals(50, r1.getPrice());
	}

	/*
	 * Test setPrice, should return 30
	 */
	@Test
	public void testSetPrice1() {
		r1.setPrice(30);
		assertEquals(30, r1.getPrice());
	}

	/*
	 * Test setPrice, should not take a negative
	 * value, return 0
	 */
	@Test
	public void testSetPrice2() {
		r1.setPrice(-30);
		assertEquals(0, r1.getPrice());
	}

	/*
	 * Test setPrice, should return 0
	 */
	@Test
	public void testSetPrice3() {
		r1.setPrice(0);
		assertEquals(0, r1.getPrice());
	}

	/*
	 * Test equalsRecipe, should return true
	 */
	@Test
	public void testEqualsRecipe1() {
		Recipe r2 = new Recipe();
		r2.setName("Coffee");
		r2.setPrice(50);
		r2.setAmtCoffee(6);
		r2.setAmtMilk(1);
		r2.setAmtSugar(1);
		r2.setAmtChocolate(1);
		
		assertTrue(r1.equals(r2));
	}
	
	/*
	 * Test equalsRecipe, should return false
	 */
	@Test
	public void testEqualsRecipe2() {
		Recipe r2 = new Recipe();
		r2.setName("Coffee2");
		r2.setPrice(50);
		r2.setAmtCoffee(6);
		r2.setAmtMilk(1);
		r2.setAmtSugar(1);
		r2.setAmtChocolate(1);
		
		assertFalse(r1.equals(r2));
	}
	
	/*
	 * Test equalsRecipe, should return false
	 */
	@Test
	public void testEqualsRecipe3() {
		Recipe r2 = new Recipe();
		r2.setName(null);
		r2.setPrice(50);
		r2.setAmtCoffee(6);
		r2.setAmtMilk(1);
		r2.setAmtSugar(1);
		r2.setAmtChocolate(1);
		
		assertFalse(r1.equals(r2));
	}
	
	/*
	 * Test equalsRecipe, should return false
	 */
	@Test
	public void testEqualsRecipe4() {
		Recipe r2 = new Recipe();
		assertFalse(r1.equals(r2));
	}

	@Test
	public void testToString() {
		assertEquals("Coffee", r1.toString());
	}
}
